/**
 * 
 */
package com.easidea.tim.dao.supply;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springside.core.dao.extend.HibernateEntityExtendDao;

import com.easidea.tim.entity.supply.Sup;
import com.easidea.tim.util.ParamsUtilities;

/**
 * @author Harrison
 *
 */
public class SupDao extends HibernateEntityExtendDao<Sup> {
	@SuppressWarnings("unchecked")
	public List<Sup> filteSupByName(String name){
		String hql = "select new com.easidea.tim.entity.supply.Sup(c.id,c.name,c.contactor,c.contactorMobile)"
			 + " from " + Sup.class.getName() 
			 + " as c where c.deleted = 0 and c.status = 1 and c.name like '" + ParamsUtilities.dealWithReservedSqlChar(name) + "%'";
		return this.getHibernateTemplate().find(hql);
	}
	
	 @SuppressWarnings("unchecked")
	public List<Sup> GetSupplierByType(Long id){
		Criteria ca = this.createUnDeletedCriteria();
		ca.add(Restrictions.eq("type.id", id));
		return ca.list();
	}
	 
	 @SuppressWarnings("unchecked")
		public List<Sup> GetAllSupplier(){
			Criteria ca = this.createUnDeletedCriteria();
			return ca.list();
		}
}

